package com.ruoyi.web.controller.system;    

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysReportType;
import com.ruoyi.system.service.ISysReportTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 举报类型字典（后台可维护）Controller
 * 
 * @author ruoyi
 * @date 2025-08-24
 */
@RestController
@RequestMapping("/system/reporttype")
public class SysReportTypeController extends BaseController
{
    @Autowired
    private ISysReportTypeService sysReportTypeService;

    /**
     * 查询举报类型字典（后台可维护）列表
     */
    @GetMapping("/list")
    @Anonymous
    public TableDataInfo list(SysReportType sysReportType)
    {
        startPage();
        List<SysReportType> list = sysReportTypeService.selectSysReportTypeList(sysReportType);
        return getDataTable(list);
    }

    /**
     * 导出举报类型字典（后台可维护）列表
     */
    @PreAuthorize("@ss.hasPermi('system:type:export')")
    @Log(title = "举报类型字典（后台可维护）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysReportType sysReportType)
    {
        List<SysReportType> list = sysReportTypeService.selectSysReportTypeList(sysReportType);
        ExcelUtil<SysReportType> util = new ExcelUtil<SysReportType>(SysReportType.class);
        util.exportExcel(response, list, "举报类型字典（后台可维护）数据");
    }

    /**
     * 获取举报类型字典（后台可维护）详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:type:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(sysReportTypeService.selectSysReportTypeById(id));
    }

    /**
     * 新增举报类型字典（后台可维护）
     */
    @PreAuthorize("@ss.hasPermi('system:type:add')")
    @Log(title = "举报类型字典（后台可维护）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysReportType sysReportType)
    {
        return toAjax(sysReportTypeService.insertSysReportType(sysReportType));
    }

    /**
     * 修改举报类型字典（后台可维护）
     */
    @PreAuthorize("@ss.hasPermi('system:type:edit')")
    @Log(title = "举报类型字典（后台可维护）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysReportType sysReportType)
    {
        return toAjax(sysReportTypeService.updateSysReportType(sysReportType));
    }

    /**
     * 删除举报类型字典（后台可维护）
     */
    @PreAuthorize("@ss.hasPermi('system:type:remove')")
    @Log(title = "举报类型字典（后台可维护）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(sysReportTypeService.deleteSysReportTypeByIds(ids));
    }
}
